#include "producer/ProducerController.h"

namespace zeroplus::mq
{
    ProducerController::ProducerController(const std::string &uri)
        : mediator_(std::make_shared<producer::ProducerMediator>())
    {

        Uri uriParser = Uri(uri);
        routeInfoDownloader_ = std::make_shared<producer::RouteInfoDownloader>(mediator_, uriParser.GetUri());
        messagePublisher_ = std::make_shared<producer::MessagePublisher>(mediator_);
        mediator_->setRouteInfoDownloader(routeInfoDownloader_);
        mediator_->setMessagePublisher(messagePublisher_);
    }

    ProducerController::~ProducerController() {}

    void ProducerController::Start()
    {
        routeInfoDownloader_->Start();
    }

}
